package com.itkang.state;

/**
 * <p>
 * 场景:
 * </p>
 *
 * @author york yuan
 * @version 1.0
 * @since 15/7/9下午2:31
 */
public class OpenLight {
    /**
     * 把所有的状态,声明为对象
     */
    State LightOnState;
    State LightOffState;

    State state = LightOnState;


    Boolean isopen;

    /**
     * 构造函数,实例化所有的对象,并设置当前的操作状态对象
     * @param isopen
     */
    public OpenLight(Boolean isopen) {
        this.isopen = isopen;
        //把当前对象传递过去,用来改变状态对象
        LightOffState = new LightOffState(this);
        LightOnState = new LightOnState(this);
        state = LightOnState;
    }

    /**
     * 调用方法,使用默认的对象操作
     */
    public void open(){
        state.handle();
    }



    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }
}
